import fetch from "@/api/fetch"
import constants from "@/api/constants"

const baseURL = constants.baseURL + "/order";

const api = {
    // 订单
    order: {
        // 分页列表
        listPage(params) {
            return fetch.get(baseURL + "/api/admin/listPage", { params });
        },
        // 详情
        infoWithCascade(orderId) {
            return fetch.get(baseURL + "/order/infoWithCascade/" + orderId);
        }
    },
    // 物流
    express: {
        // 详情
        infoByOrderId(orderId) {
            return fetch.get(baseURL + "/express/infoByOrderId/" + orderId);
        },
        // 发货
        consignOrder(form) {
            return fetch.post(baseURL + "/express/consignOrder", form);
        },
        // 编辑发货信息
        update(form) {
            return fetch.post(baseURL + "/express/update", form);
        }
    },
    // 退款
    refund: {
        // 售后列表
        listForAdmin(orderId) {
            return fetch.get(baseURL + "/refund/listForAdmin/" + orderId);
        },
        // 售前同意
        approveRefund(id, repeatSubmitToken) {
            return fetch.post(baseURL + "/refund/approveRefund/" + id + "?repeat-submit-token=" + repeatSubmitToken);
        },
        // 售前拒绝
        refuseRefund(form) {
            return fetch.post(baseURL + "/refund/refuseRefund", form);
        },
        // 售后同意
        approveReturn(id, repeatSubmitToken) {
            return fetch.post(baseURL + "/refund/approveReturn/" + id + "?repeat-submit-token=" + repeatSubmitToken);
        },
        // 售后拒绝
        refuseReturn(form) {
            return fetch.post(baseURL + "/refund/refuseReturn", form);
        },
        // 退货收货
        returnDeliveryReceive(id, repeatSubmitToken) {
            return fetch.post(baseURL + "/refund/returnDeliveryReceive/" + id + "?repeat-submit-token=" + repeatSubmitToken);
        },
    }
}

export default api;